-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix android phone authentication #308
base: master
Are you sure you want to change the base?
Fix android phone authentication #308
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! And sorry for the delay in reviewing.
What about JS and iOS, do they suffer the same issue?
@@ -104,6 +101,9 @@ actual class PhoneAuthProvider(val android: com.google.firebase.auth.PhoneAuthPr | |||
} | |||
} | |||
|
|||
override fun onCodeAutoRetrievalTimeOut(verificationId: String) { | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll need to fail the CompletableDeferred here too otherwise it will hang?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we should make a response.complete() in onCodeAutoRetrievalTimeOut(), because the response can be completed only once and we would not be able to make response.complete() after user input when onCodeAutoRetrievalTimeOut() is called before.
Maybe we could add a function inside PhoneVerificationProvider: onCodeAutoRetrievalTimeOut()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't want to complete, you fail it with the appropriate exception
@@ -104,6 +101,9 @@ actual class PhoneAuthProvider(val android: com.google.firebase.auth.PhoneAuthPr | |||
} | |||
} | |||
|
|||
override fun onCodeAutoRetrievalTimeOut(verificationId: String) { | |||
} | |||
|
|||
override fun onVerificationCompleted(credential: com.google.firebase.auth.PhoneAuthCredential) { | |||
response.complete(Result.success(AuthCredential(credential))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know this isnt your code but we shoudlnt be wrapping the result in a Result - can just fail the CompletableDeferred with completeExceptionally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So instead of response.complete(Result.failure(exception)) we should do response.completeExceptionally(exception)?
Hello, sorry for the late reply! |
Current behavior blocks sms code user input until auto retrieval timeout is reached.
Documentation states it is not recommended to enable user input after sms code retrieval timeout, we should rather enable user input after code sent.
https://firebase.google.com/docs/auth/android/phone-auth#oncodeautoretrievaltimeoutstring-verificationid
So I moved the
getVerificationCode()
fromonCodeAutoRetrievalTimeOut()
toonCodeSent()
and it works well on my project.